<template>
  <div class="home_two">
    <div class="titlea">
      <p>
          {{gettime}} 月报表
      </p>
      <!-- 本月 上月 -->
     <div style="margin-top:20px">
        <span :class="{nowColor :ends==1}" @click="addCountrysClass">本月</span>
      <span :class="{nowColor :ends==2}" @click="addCountrys">上月</span>
     </div>
      
  
      
    </div>
    <el-table size="mini" :data="tableData" border style="width: 100%">
      <el-table-column prop="moduleName" label="彩种"></el-table-column>
      <!-- <el-table-column prop="issue" label="期数"></el-table-column> -->
      <el-table-column prop="quantity" label="笔数"></el-table-column>
      <el-table-column prop="totalBets" label="总投"></el-table-column>
      <el-table-column prop="profit" label="盈亏"></el-table-column>
    </el-table>
    
      
  </div>
</template>

<script>
import { mapState } from "Vuex";
export default {
  name: "homeOne",
  data() {
    return {
       pageNum: 1,
      total: 0,
      ends: 1,
      gettime: "", //当前时间
      tableData: [],
      startTime: "",
      endTime: "",
       pritem: this.$route.query.titleid
    };
  },
  created(){
      this.currentTime();
      this.fetchData()
  },
  computed: {
    ...mapState(["typedt"]),
  },
  methods:{
     // 点击变色
    addCountrysClass() {
      this.ends = 1;
      this.fetchData()
      console.log(this.ends, 777);
    },
    addCountrys() {
      this.ends = 2;
      this.fetchData()
      console.log(this.ends, 333);
    },
     currentTime() {
      setInterval(this.getTime, 500);
    },
      // 接口
    fetchData() {
      this.$api.post(
        this.$url.accountBook,
        {
          month:this.ends,
           module:this.typedt
        },
        res => {
          if (res.data.code == 200) {
            console.log(res.data,"月")
            this.tableData = res.data.data;
            this.total = res.data.count;
          } else {
            this.$message.error(res.data.msg);
          }
        }
      );
    },
      getTime() {
      var _this = this;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let hh = new Date().getHours();
      let mf =
        new Date().getMinutes() < 10
          ? "0" + new Date().getMinutes()
          : new Date().getMinutes();
      let ss =
        new Date().getSeconds() < 10
          ? "0" + new Date().getSeconds()
          : new Date().getSeconds();
      _this.gettime = yy + "-" + mm + "-" + dd;
    }
  }
};
</script>
<style lang="less" scoped>
// 历史账单
.home_two {
  width: 100%;
  .titlea {
    margin: 30px 10px;
    p {
        background: #eee;
        color: #000;
        line-height: 30px;
        padding-left: 20px;
        font-weight: 700;
    }
    span {
      padding: 0px 10px;
    }
  }
}
.nowColor {
  color: #999999;
}
</style>
